 package net.go176.backpack.core;
 
 import cpw.mods.fml.common.Loader;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Field;
 import java.lang.reflect.InvocationTargetException;
 import java.util.ArrayList;
 import java.util.EnumMap;
 import java.util.List;
 import java.util.Map;
 import net.go176.backpack.api.AccessorGroup;
import net.go176.backpack.api.IDataAccessor;
import net.go176.backpack.core.compatible.VanillaHandler;
import net.go176.backpack.Backpack;



 import net.go176.backpack.gui.InventoryType;
 import org.bukkit.Bukkit;
 import org.bukkit.plugin.Plugin;
 
 
 
 
 public class CoreHelper
 {
   public final String obcVersion;
   public final String nmsVersion;
   public final boolean isMCPServer;
   private Backpack p;
   private DataManager dataMan;
   private Map<DataType, String> appliedCores = new EnumMap<>(DataType.class);
   
   private Map<DataType, MyDataHandler> dataHandlerMap = new EnumMap<>(DataType.class);
   private List<IDataAccessor> accessorList = new ArrayList<>((DataType.values()).length);
   
   public CoreHelper(Backpack plugin) {
     String[] split = Bukkit.getServer().getClass().getPackage().getName().split("\\.");
     this.obcVersion = split[split.length - 1];
     boolean mcp = false;
     try {
       Class.forName("cpw.mods.fml.common.Loader");
       mcp = true;
     } catch (ClassNotFoundException classNotFoundException) {}
     this.isMCPServer = mcp;
     this.nmsVersion = this.isMCPServer ? Loader.instance().getMCPVersionString() : this.obcVersion;
 
 
     
     this.p = plugin;
     this.dataMan = this.p.getDataManager();
   }
   
   public void initCore() {
     this.appliedCores.put(DataType.VANILLA, "compatible");
     VanillaHandler dataHandler = new VanillaHandler(this.p);
     this.dataHandlerMap.put(DataType.VANILLA, dataHandler);
     this.accessorList.add(dataHandler);
   }
   
   public ModFinder initCoreEx(DataType type) throws ClassNotFoundException, NoSuchMethodException, SecurityException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchFieldException {
     return initCoreEx(type, getExpectedCore());
   }
   
   public ModFinder initCoreEx(DataType type, String coreVersion) throws ClassNotFoundException, NoSuchMethodException, SecurityException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchFieldException {
     ModFinder finder = null;
     if (type != DataType.VANILLA) {
       finder = new ModFinder(type.mainClass, coreVersion, String.valueOf(type.name) + "Handler", null);
       this.appliedCores.put(type, coreVersion);
       this.dataHandlerMap.put(type, finder.dataHandler);
       this.accessorList.add(finder.dataHandler);
     } 
     return finder;
   }
   
   public void setupAccessorGroup() {
     this.dataMan.setupAccessorGroup(new AccessorGroup((Plugin)this.p, "GroupMyBackpack"), this.accessorList);
   }
   
   public String getAppliedCore(DataType type) {
     return this.appliedCores.get(type);
   }
   
   public MyDataHandler getDataHandler(DataType type) {
     return this.dataHandlerMap.get(type);
   }
   
   public MyDataHandlerGUI getDataHandlerGUI(InventoryType invType) {
     MyDataHandler handler = this.dataHandlerMap.get(invType.dataType);
     if (handler instanceof MyDataHandlerGUI)
       return (MyDataHandlerGUI)handler; 
     return null;
   }
   
   public class ModFinder
   {
     public final MyDataHandler dataHandler;
     public final String modVersion;
     
     private ModFinder(String mainClass, String coreVersion, String handler) throws ClassNotFoundException, NoSuchMethodException, SecurityException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchFieldException {
       Class<?> modClass = Class.forName(mainClass);
       Field f = modClass.getDeclaredField("VERSION");
       Constructor<?> constructor = Class.forName(String.valueOf(getClass().getPackage().getName()) + "." + coreVersion + "." + handler).getConstructor(new Class[] { Backpack.class });
       this.modVersion = (String)f.get(null);
       this.dataHandler = (MyDataHandler)constructor.newInstance(new Object[] { CoreHelper.access$0(this$0) });
     }
   }
 
   
   public String getExpectedCore() {
     return this.isMCPServer ? ("mcp" + this.nmsVersion.substring(5, this.nmsVersion.length() - 1).replace(".", "_")) : this.nmsVersion;
   }
 }


/* Location:              D:\User\Xuan\Downloads\MyBackpack1.2.5.jar!\net\saralab\mybackpack\core\CoreHelper.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       1.1.3
 */